# import time
# from concurrent.futures.thread import ThreadPoolExecutor
# from threading import Thread
#
# import ujson
# import requests
#
#
# class Beauty:
#
#     def __init__(self, ctime, title, description, picUrl, url):
#         self.ctime = ctime
#         self.title = title
#         self.description = description
#         self.pic_url = picUrl
#         self.url = url
#
#
# def download_image(image_url):
#     resp = requests.get(image_url)
#     filename = image_url[image_url.rfind('/') + 1:]
#     with open(f'images/{filename}', 'wb') as file:
#         file.write(resp.content)
#
#
# def main():
#     resp = requests.get(
#         'http://api.tianapi.com/meinv/index?key=9636cec76ee2593ba6b195e5b770b394&num=50'
#     )
#     data = ujson.loads(resp.content)
#     pool = ThreadPoolExecutor(max_workers=16)
#     start = time.time()
#     futures = []
#     for beauty_dict in data['newslist']:
#         model = Beauty(**beauty_dict)
#         futures.append(pool.submit(download_image, model.pic_url))
#     for future in futures:
#         future.result()
#     end = time.time()
#     print(f'执行时间: {end - start:.1f}秒')
#
#
# if __name__ == '__main__':
#     main()
